<?php


namespace app\validate\topic;


use think\Validate;

class TopicValidate extends Validate
{
    protected $rule = [
        'id' => 'require',
        'chapter_id' => 'require',
        'title' => 'require',
        'title_id' => 'require|unique:topic,title_id^chapter_id',
        'option' => 'require',
        'analysis' => 'require',
    ];


    protected $message = [
        'id.require' => 'id不能为空',
        'chapter_id.require' => '请选择章节',
        'title_id.require' => '题号不能为空',
        'title_id.unique' => '题号重复',
        'title.require' => '题目不能为空',
        'option.require' => '请添加选项',
        'analysis.require' => '请添加解析',
    ];

    protected $scene = [
        'add' => ['chapter_id', 'title_id', 'title', 'option', 'analysis'],
        'edit' => ['id', 'chapter_id', 'title_id', 'title', 'option', 'analysis'],
    ];
}